﻿using System.Linq;
using Yyyg.Models;

namespace Yyyg.BLL
{
    public static class AdminOper
    {
        /// <summary>
        /// 确认是否登录成功
        /// </summary>
        public static bool Login(string mob, string pwd)
        {
            using (LuckyEntities luck = new LuckyEntities())
            {
                return luck.Admins.Any(a => a.Mobile == mob && a.Pwd == pwd);
            }
        }

        /// <summary>
        /// 返回单个管理员实例
        /// </summary>
        /// <param name="mob"></param>
        /// <returns></returns>
        public static string GetAdminName(string mob)
        {
            using (LuckyEntities luck = new LuckyEntities())
            {
                return luck.Admins.First(a => a.Mobile == mob).Uname;
            }
        }

        /// <summary>
        /// 确认是否包含指定账号
        /// </summary>
        public static bool HasMob(string mob)
        {
            using (LuckyEntities lucky = new LuckyEntities())
            {
                return lucky.Admins.Any(a => a.Mobile == mob);
            }
        }
    }
}
